<%--
  Created by IntelliJ IDEA.
  User: 10475
  Date: 2023/2/23
  Time: 11:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加企业</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" media="all">
    <script src="${pageContext.request.contextPath}/lib/layui-v2.6.3/layui.js"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<h2>添加学生</h2>

<%--lay-filter="useradmin" id="useradmin"--%>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">账&nbsp;号：</label>
        <div class="layui-input-inline">
            <input type="text" id="userId" name="userId" lay-verify="required" value="${user.userId}" autocomplete="off" class="layui-input" readonly="readonly">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">密 码：</label>
        <div class="layui-input-inline">
            <input type="text" id="pwd" name="pwd" lay-verify="required" value="${user.pwd}" autocomplete="off" class="layui-input" readonly="readonly">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">用户名：</label>
        <div class="layui-input-inline">
            <input type="text" id="name" name="name" lay-verify="required" value="${user.name}" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名：</label>
        <div class="layui-input-inline">
            <input type="text" id="realName" name="realName"  value="${user.realName}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">性别:</label>
            <div class="layui-input-inline">
                <select name="uSex" id="uSex">
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年 龄:</label>
        <div class="layui-input-inline">
            <input type="text" id="age" name="age"  value="${user.age}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">毕业院校:</label>
        <div class="layui-input-inline">
            <input type="text" id="school" name="school"  value="${user.school}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">学历:</label>
        <div class="layui-input-inline">
            <input type="text" id="xueLi" name="xueLi"  value="${user.xueLi}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">专业:</label>
        <div class="layui-input-inline">
            <input type="text" id="major" name="major"  value="${user.major}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">身份证号:</label>
        <div class="layui-input-inline">
            <input type="text" id="cardNum" name="cardNum"  value="${user.cardNum}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">电&nbsp;话:</label>
        <div class="layui-input-inline">
            <input type="text" id="tel"  value="${user.tel}" name="tel" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">***个人描述：</label>
        <div class="layui-input-inline">
            <textarea placeholder="请输入内容"  value="${user.description}" class="description" id="description">${user.description}</textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1" onclick="submitCompany()">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script type="text/javascript">
    function submitCompany() {
        var pwd=$("#pwd").val();
        var userId=$("#userId").val();
        var realName=$("#realName").val();
        var uSex=$("#uSex").val();
        var school=$("#school").val();
        var xueLi=$("#xueLi").val();
        var name=$("#name").val();
        var major=$("#major").val();
        var cardNum=$("#cardNum").val();
        var tel=$("#tel").val();
        var description=$("#description").val();
        var age=$("#age").val();

        console.log(name);

        if(userId.length==0||realName.length==0||uSex.length==0||school.length==0||
            xueLi.length==0||name.length==0||major.length==0||cardNum.length==0||
            tel.length==0||description.length==0||age.length==0){
            layer.msg('必填项没有填！！请重新填',{icon: 5});
        }else if(tel.length!=11) {
            layer.msg('电话填写有误',{icon: 5});
        }else if(cardNum.length!=18) {
            layer.msg('身份证号码填写有误', {icon: 5});
        }else{
            $.ajax({
                url: "${pageContext.request.contextPath}/EditUserInfo",
                type: 'post',
                dataType: 'text',
                data: {
                    'userId':userId,
                    'name':name,
                    'uSex':uSex,
                    'school':school,
                    'xueLi':xueLi,
                    'major':major,
                    'cardNum':cardNum,
                    'tel':tel,
                    'description':description,
                    'realName':realName,
                    'age':age,
                    'pwd':pwd,
                },
                success: function (res) {
                    alert("添加成功");
                },

                error: function (res) {
                    alert("添加失败");
                }
            });

        }


    }
</script>
<script>
    layui.use('form', function(){
        var form = layui.form;
    });
</script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#addTime'
        });
    });
</script>
</html>
